﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using MyBlog.DataAccess;
using MyBlog.Model;
using MyBlog.Common;
using AutoMapper;
using MyBlog.BusinessInterface;
using MyBlog.DataEntity;
using MyBlog.DataAccessInterface;

namespace MyBlog.Business
{
    public class BusinessVisitor : IBusinessVisitor
    {
        IDALVisitor _dalVisitor;
        IUnitOfWork _unitWork;
        public BusinessVisitor(IDALVisitor dalVisitor, IUnitOfWork unitWork)
        {
            _dalVisitor = dalVisitor;
            _unitWork = unitWork;
        }
        public void Add(VisitorModel entity)
        {
            var dataEntity = Mapper.Map<Tbl_Visitor>(entity);
            _dalVisitor.Add(dataEntity);
            _unitWork.Commit();
        }

        public List<VisitorModel> GetAll(bool isTracking = true)
        {
            var entities = _dalVisitor.GetAll(isTracking);
            return entities.MapToList<Tbl_Visitor, VisitorModel>();
        }

        public List<VisitorModel> GetAll(VisitorModel model, bool isTracking = true)
        {
            var where = LinqExpressionBuilder.True<Tbl_Visitor>();
            var entities = _dalVisitor.GetAll(where, isTracking);
            return entities.MapToList<Tbl_Visitor, VisitorModel>();
        }


        public void AddRange(IEnumerable<VisitorModel> entities)
        {
            throw new NotImplementedException();
        }

        public void Update(VisitorModel entity)
        {
            throw new NotImplementedException();
        }

        public void Delete(params object[] primaryKey)
        {
            throw new NotImplementedException();
        }

        public void Delete(VisitorModel entity)
        {
            throw new NotImplementedException();
        }

        public void DeleteRange(IEnumerable<VisitorModel> entities)
        {
            throw new NotImplementedException();
        }

        public VisitorModel Get(params object[] primaryKey)
        {
            throw new NotImplementedException();
        }

        public VisitorModel Get(VisitorModel entity)
        {
            throw new NotImplementedException();
        }

        public List<VisitorModel> GetAll(VisitorModel model, int page, int size, out int total, bool isTracking = true)
        {
            throw new NotImplementedException();
        }
    }
}
